import Vue from 'vue'
import Vuex from 'vuex'

import persistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: [],
    showlogin: false,
    // 购物车
    cart: []
  },
  getters: {
    userID(state) {
      return state.user.user_id
    },
   
  },
  mutations: {
    //获取到购物车
    cart(state, cart) {
      state.cart = cart
    },
    //判断登录框是否弹出
    editshow(state) {
      state.showlogin = !state.showlogin
    },
    //添加
    push(state, obj) {
      state.user = obj
    },
    //退出
    shan(state) {
      state.user = []
    },
  },
  actions: {
  },
  modules: {
  },
  plugins: [persistedState(window.localStorage)]
})
